﻿@model IEnumerable<TCC.CMFlow.Models.CategoriaWebServiceAtributo>

@foreach (var item in Model.OrderBy(o => !o.Ordem.HasValue ? 1 : 0).ThenBy(o => o.Ordem))
{
    <div class="panel panel-default">
        <div class="panel-heading clearfix">
            <h3 class="panel-title pull-left">
                @if (item.Childrens.Any())
                {
                    <a data-toggle="collapse" data-target="#collapse@(item.ID)" href="#collapse@(item.ID)" style="text-decoration:none">
                        <span class="glyphicon glyphicon-chevron-down">&nbsp;</span>
                        @Html.DisplayFor(modelItem => item.Nome)
                    </a>
                }
                else
                {
                    @Html.DisplayFor(modelItem => item.Nome)
                }
                <small>@(string.IsNullOrEmpty(item.Apelido) ? string.Empty : "(" + item.Apelido + ")")</small>
                @if (item.IsPrimaryKey)
                {
                    <span class="text-warning glyphicon glyphicon-asterisk"></span>
                }
            </h3>

            <div class="pull-right">
                <a data-modal="" class="btn btn-default btn-xs" href="@Url.Action("ConfigurarAtributo", new { atributoID = item.ID, categoriaWorkflowID = item.CategoriaWorkflowID })" id="btnApelido"><span class="glyphicon glyphicon-wrench"></span> Configurações</a>
            </div>
        </div>

        <div id="collapse@(item.ID)" class="panel-collapse collapse">
            @Html.Partial("_CategoriaWebServiceAtributos", item.Childrens)
        </div>
    </div>
}
